package OOday03;
//引用类型数组演示
public class RefArrayDemo {
    public static void main(String[] args) {
        /*//声明Dog型数组dogs,包含3个元素,每个元素都是Dog型,默认值为NULL
        Dog[] dogs = new Dog[3];

        Chick[] chicks = new Chick[2];

        Fish[] fish = new Fish[2];*/

        /*Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑",2,"黑");
        dogs[1] = new Dog("小白",2,"白");
        dogs[2] = new Dog("小黄",3,"黄");

        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("小花",1,"花");
        chicks[1] = new Chick("大花",1,"花");

        Fish[] fish = new Fish[4];
        fish[0] = new Fish("大金",2,"金");
        fish[1] = new Fish("小金",2,"金");
        fish[2] = new Fish("大绿",2,"绿");
        fish[3] = new Fish("大红",2,"红");*/
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑",2,"黑");
        dogs[1] = new Dog("小白",2,"白");
        dogs[2] = new Dog("小灰",2,"灰");
        System.out.println(dogs[0].name);
        dogs[1].age = 4;
        dogs[2].swim();
        for (int i=0;i< dogs.length;i++){
            System.out.println(dogs[i].name);//输出每只狗狗名字
            dogs[i].eat();//每只狗狗吃饭
        }
    }
}
